<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>{$activityname}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
<link href="{$Think.config.RESOURCEURL}wx_assets/love/love.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
    <if condition="$userInfo.receiptorUserName neq ''">
        <style>
            body{background-color:white}
        </style>
    <else/>
        <style>
            body{background-color:#A34437}
        </style>
    </if>
</head>
<body>
<div>
    <if condition="$userInfo.receiptorUserName neq ''">
            <div class="perInfo whiteBg">
                <div class="">
                    <div class="perImg">
                        <img src="{$userInfo.headimgurl}"/>
                        <span class="name">{$userInfo.nickname}</span>
                    </div>
                    <span class="bg-common ico-right"></span>
                    <div class="perImg">
                        <img src="{$userInfo.headimgurl1}"/>
                        <span class="name">{$userInfo.nickname1}</span>
                    </div>
                </div>
                <span class="title title_common">{$jsonstr.VIEW_INFO_3.info}</span>
                <div class="line"></div>
                <div class="love-img">
                    <img src="{$jsonstr.VIEW_PRODUCT_PIC.src}">
                </div>
            </div>
            <div class="cont-btn">
                <!--<a class="button" onclick="detail.toIndex()">我也要送</a>-->
                <a class="bg-common js-btn"  style="background-image:url({$jsonstr.VIEW_BUTTON_MESEND.src})" onclick="detail.toIndex()">&nbsp;</a>
            </div>
        <else/>
            <div class="perInfo">
                <div class="perImg">
                    <img class="answer-btn" src="{$userInfo.headimgurl}"/>
                    <span class="name" style="color:white">{$userInfo.nickname}</span>
                </div>
                    <span class="small_title">{$jsonstr.VIEW_INFO_1.info}</span>
                <span class="title" style="color:white">{$jsonstr.VIEW_INFO_2.info}</span>
            </div>
            <div class="answerDiv"><a class="bg-common answer-btn receive"  id="SaveBtn" style="background-image:url({$jsonstr.VIEW_BUTTON_TIJIAO.src})">&nbsp;</a></div>
            <div class="cont-btn">
                <if condition="$fromRegId neq ''">
                    <a class="bg-common js-btn" onclick="detail.toIndex()" style="background-image:url({$jsonstr.VIEW_BUTTON_MEWSEN.src})"></a>
                    <else/>
                    <a class="bg-common js-btn"  id="shareBtn" style="background-image:url({$jsonstr.VIEW_BUTTON_MESEND.src})"></a>
                </if>
            </div>

            <div class="collects" id="AnswerLayer" >
            <div class="bg-common wrongp" id="AnswerLayer_close" style="background-image:url({$jsonstr.VIEW_BUTTON_CLOSE.src});"></div>
            <div class="dtitle">
                “输入暗号 领取礼物”
            </div>
            <div class="tosignalDiv">
                <dl class="tosignal">
                    <dt><input class="mysignal" value="{$userInfo.question}" readonly="readonly" type="text"></dt>
                </dl>
                <dl class="tosignal">
                    <dt style="border:0"><input class="mysignal" id="answer" type="text" placeholder="输入你的答案"></dt>
                </dl>
            </div>
            <div class="tosignal">
                <dd>&nbsp;</dd>
                <dt class="errInfo">
                    <label id="errInfo" >不对，不对，你再想想！</label>
                </dt>
            </div>
            <div class="button" id="answerSaveBtn">立即领取</div>
    </div>
        <div class="mask">
        </div>
    </if>
</div>
    <div class="collects opacityDiv" id="addressBox">
        <div class="bg-common wrongp" id="Address_close" style="background-image:url({$jsonstr.VIEW_BUTTON_CLOSE.src});"></div>
        <div class="imgDiv"><img src="{$jsonstr.VIEW_PRODUCT_PIC.src}"></div>
            <div class="address">
                <span class="left_text">收货人：</span>
                <span class="right_text"><input type="text" id="fullName"/></span>
            </div>
            <div class="address">
                <span class="left_text">手机号：</span>
                <span class="right_text"><input type="tel" id="phone"/></span>
            </div>
            <div class="address">
                <span class="left_text">地&nbsp;&nbsp;&nbsp;址：</span>
                <span class="right_text"><input type="text" id="address"/></span>
            </div>
            <div class="button" id="BtnSaveAddress" style="margin:30px 10px 10px">确定</div>
    </div>
<script>
var baseUrl = '{$Think.config.SERVER_HOST}';
var detail={
    init:function(){
        this._initEvent();
        this._initValidate();
//        $(".opacityDiv").click(function(e){
//            if(e.target.tagName.toUpperCase()!="INPUT"){
//                window.scroll(0,0);
//            }
//        });
    },
    _take:function(){
        $("#AnswerLayer").removeClass("collects-show"); 
        $("#SaveBtn").removeClass("rotate-btn");
        $("#addressBox").addClass("collects-show").show();
    },
    toIndex:function(){
        var p=$.util.getParamAsObject();
        var params={
            "actId":"{$actId}",
            "miUId":p.miUId,
            "qId":p.qId,
            "fromGuid":p.fromGuid || ""
        }
        params=encodeURIComponent(JSON.stringify(params));
        location.href= 'call.html?customerId={$customerId}&module=love&method=index&params='+params;
    },
    _initEvent:function(){
        var isProblem="{$userInfo.isProblem}";
        var me=this;
        $("#SaveBtn").click(function(){
            $(this).addClass("rotate-btn");
            $(this).one("webkitTransitionEnd",function(){
                //动画结束
                if(isProblem){ //如果设置了问题
                    $("#AnswerLayer").addClass("collects-show").show(); 
                } else {
                    me._take();
                }
            });
        });
        $("#shareBtn").click(function(){
           $(".mask").addClass("showMask");
        });
        $(".mask").click(function(){
           $(this).removeClass("showMask");
        });
        $("#AnswerLayer_close").click(function(){
            $("#AnswerLayer").removeClass("collects-show"); 
            $("#SaveBtn").removeClass("rotate-btn");
        });
        $("#Address_close").click(function(){
            $("#addressBox").removeClass("collects-show");
            $("#SaveBtn").removeClass("rotate-btn");
        });
        $("#answerSaveBtn").click(function(){
            me._answer();
        });
    },
    _saveAddress:function(){
        var fullName=$("#fullName").val();
        var phone=$("#phone").val();
        var address=$("#address").val();
        if(!fullName){
            $.util.alert("请输入收货人姓名");
            return;
        }
        if(!phone){
            $.util.alert("请输入收货人电话");
            return;
        }
        if(!address){
            $.util.alert("请输入收货详细地址");
            return;
        }
        if(!$("#BtnSaveAddress").hasClass("btn-disabled")){
            $.util.pageLoading.show();
            $("#BtnSaveAddress").addClass("btn-disabled");
            $.req.get("call.json?customerId={$customerId}&module=love&method=savereceiptor", {
                params: {
                    "regId":"{$regId}",
                    "actId":"{$actId}",
                    "oid":"{$userInfo.oid}",
                    "fullName":$("#fullName").val(),
                    "phone":$("#phone").val(),
                    "address":$("#address").val()
                }
            }, function(data) {
                if(!data.code){
                    var name = '{$userInfo.nickname}';
                    $.util.showMsg("OK，你已经成功领取了"+name+"的礼物！走，我也去送一个！",function(){
                        var params={
                            "actId":"{$actId}"
                        };
                        params=encodeURIComponent(JSON.stringify(params));
                        location.href= 'call.html?customerId={$customerId}&module=love&method=index&params='+params;
                    });
                } else {
                    $.util.showMsg(data.msg);
                }
                $("#BtnSaveAddress").removeClass("btn-disabled");
                $.util.pageLoading.hide();
            });
        }
    },
    _initValidate:function(){
        var me=this;
        $("#BtnSaveAddress").click(function() {
            me._saveAddress();
        });
    },
    _answer:function(){
        var isProblem="{$userInfo.isProblem}";
        var me=this;
        var answer=$.trim($("#answer").val());
        if(!answer) {
            $.util.alert("请填写问题答案！");
            return;
        }
        $.util.pageLoading.show();
        $.req.get("call.json?customerId={$customerId}&module=love&method=getanswerinfo",{
            userName:"{$userName}",
            params:{
                "actId":"{$actId}",
                "regId":"{$regId}",
                "answer":$("#answer").val()
            }
        },function(data){
            $.util.pageLoading.hide();
            if(!data.code){
               me._take();
               $("#errInfo").css("visibility","hidden");
            } else {
                 $("#errInfo").css("visibility","visible");
            }
        });
    },
    getShareUrl:function(){
        var p=$.util.getParamAsObject();
        var shareUrl="";
        var params={
            "actId":"{$actId}",
            "qId":p.qId,
            "miUid":p.miUid,
            "fromGuid":p.fromGuid,
            "fromRegId":"{$regId}"
        };
        params=encodeURIComponent(JSON.stringify(params));
        shareUrl=baseUrl+'call.html?customerId={$customerId}&module=love&scope=1&method=view&params='+params;
        return shareUrl;
    }
}
detail.init();
var shareUrl=detail.getShareUrl();
wx_share.init({
    "title":"{$title1}",
    "desc":'{$description1}',
    "link":shareUrl,
    "imgUrl":"{$userInfo.headimgurl}",
    "pkg":{
        "appId": '{$pkg.appId}',
        "timestamp": {$pkg.timestamp},
        "nonceStr": '{$pkg.nonceStr}',
        "signature": '{$pkg.signature}'
    },
    success:function(config,shareType){
        var p=$.util.getParamAsObject();
        $.req.get("call.json?customerId={$customerId}&module=quan&method=saveShare",{
            params:{
                "qId":p.qId,
                "sId":"{$sId}",
                "guid":"{$guid}",
                "fromGuid":p.fromGuid,
                "miUId":"{$fromUId}",
                "shareType":shareType,
                "fromPage":"love_index"
            }
        },function(data){
            if(data && !data.code){

            }
        });
    }
 });
</script>
</body>
</html>